import { RewardItem } from "./RewardItem";
import { ObjCreate } from "../../common/ObjCreate";
import { FilterConst } from "../../../../component/gconst/FilterConst";
import { SReward } from "../../../../../Message/Public/SReward";
import { GameDefConfig } from "../../../resource/GameDefConfig";
import { EReward } from "../../../../../Message/Public/EReward";
import { SkillStateConfig } from "../../../resource/SkillStateConfig";
import { HTMLUtil } from "../../../../../com/gengine/utils/HTMLUtil";
import { GTextFiled } from "../../../../../com/mui/controls/GTextFiled";
//class RewardLabel
    
    export  class RewardLabel extends RewardItem
    {
        constructor()
        {
            super();
            return;
        }

        protected /* override */ createDisposedChildrenImpl(): void
        {
            super.createDisposedChildrenImpl();
            this._rewardLable = ObjCreate.createGTextField("");
            this._rewardLable.autoSize = flash.text.TextFieldAutoSize.LEFT;
            this._rewardLable.selectable = false;
            this._rewardLable.textColor = 16580298;
            this._rewardLable.filters = [FilterConst.nameGlowFilter];
            addChild(this._rewardLable);
            return;
        }

        protected /* override */ disposeImpl(arg1: Boolean=true): void
        {
            this._rewardLable.dispose();
            super.disposeImpl();
            return;
        }

        public /* override */ updateData(arg1: SReward): void
        {
            var loc2=null;
            var loc3=null;
            super.updateData(arg1);
            var loc1=GameDefConfig.instance.getRewardDef(arg1.type);
            if (loc1) 
            {
                loc2 = "#ffff00";
                if (loc1.text1 && !(loc1.text1 == "")) 
                {
                    loc2 = loc1.text1;
                }
                var loc4=arg1.type;
                switch (loc4) 
                {
                    case EReward._ERewardBufferGroup:
                    {
                        if (loc3 = SkillStateConfig.instance.getInfoByName(arg1.code)) 
                        {
                            this._rewardLable.htmlText = HTMLUtil.addColor(loc1.name.split("　").join("") + "：" + HTMLUtil.addColor(loc3.name, loc2), "#fcfeca");
                        }
                        break;
                    }
                    default:
                    {
                        this._rewardLable.htmlText = HTMLUtil.addColor(loc1.name.split("　").join("") + "：" + HTMLUtil.addColor(arg1.num.toString(), loc2), "#fcfeca");
                    }
                }
            }
            return;
        }

        public /* override */ dispose(arg1: Boolean=true): void
        {
            return;
        }

        public /* override */ get height(): number
        {
            return this._rewardLable.height;
        }

        /* internal */ /* var */_rewardLable: GTextFiled;
    }
